Sometimes we need to put a customer help form on the sidebar of the website. Start by putting a button there, and then slide out the content after clicking. Generally, we will use js to control this effect. Now css3 can do it too.
How is this done? That will use the :target tag in CSS3.
Let's take a look at the implementation of this animation.
1. Fix the box at a certain location.
2. Hide the form inside and only expose a click button.
3. When the button is clicked, the form is drawn and the button text is changed.
4. Click the button again and the form is indented.
HTML CODE:
<h1><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Slide-in slide-out</font></font></h1>
<h2><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Click it, then click Hide</font></font></h2>
<div id="volet_clos">
<div id="volet">
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Lorem Alsace ipsum chime amet sed bissame so libero. </font><font style="vertical-align: inherit;">DNA, John Richard</font></font></p>
<p><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Sorrow elementum semper tellus s'guelt Pfourtz</font></font></p>
<a href="#volet" class="ouvrir" aria-hidden="true"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Slide out</font></font></a>
<a href="#volet_clos" class="fermer" aria-hidden="true"><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">Slide in</font></font></a>
</div>
</div>
CSS CODE:
<style type="text/css">
<!--
body {
margin: 0;
padding: 10px 40px;
background: #F1EFE2;
font-size: 1.4em;
font-family: georgia, "trebuchet ms", arial, serif;
height: 3000px; /* test fixed + scroll */
}
h1 {
margin-top: 20px;
margin-bottom: 40px;
color: #345;
text-shadow: 1px 1px 1px #fff;
}
h2 {
color: #678;
text-shadow: 1px 1px 1px #fff;
font-size: 1.1em;
}
#volet {
width: 250px;
padding: 10px;
background: #6B9A49;
color: #fff;
}
#volet a.ouvrir,
#volet a.fermer {
padding: 10px 25px;
background: #555;
color: #fff;
text-decoration: none;
}
#volet {
position: absolute;
left: -270px; /* test fixed + scroll, position top */
-webkit-transition: all .5s ease-in;
-moz-transition: all .5s ease-in;
transition: all .5s ease-in;
}
#volet a.ouvrir,
#volet a.fermer {
position: absolute;
right: -88px;
top: 150px;
-webkit-transform: rotate(270deg);
-moz-transform: rotate(270deg);
-o-transform: rotate(270deg);
-ms-transform: rotate(270deg);
-moz-radius: 0 0 8px 8px;
border-radius: 0 0 8px 8px;
}
#volet a.fermer {
display: none;
}
#volet:target {
left: 10px;
}
#volet:target a.fermer {
display: block;
}
#volet:target a.ouvrir {
display: none;
}
#volet_clos:target #volet {
left: -270px;
}
/* test fixed + scroll */
#volet_clos {
position: fixed;
top: 55px;
left: 0;
}
-->
</style>
Post your comments / questions
Recent Article
- How to create custom 404 error page in Django?
- Requested setting INSTALLED_APPS, but settings are not configured. You must either define..
- ValueError:All arrays must be of the same length - Python
- Check hostname requires server hostname - SOLVED
- How to restrict access to the page Access only for logged user in Django
- Migration admin.0001_initial is applied before its dependency admin.0001_initial on database default
- Add or change a related_name argument to the definition for 'auth.User.groups' or 'DriverUser.groups'. -Django ERROR
- Addition of two numbers in django python
Related Article